﻿using System;
using System.Collections.Generic;
using EnglishWords.Logic;
using System.Windows.Forms;

namespace EnglishWords
{
    public partial class UsersForm : Form
    {
        public UsersForm()
        {
            InitializeComponent();
        }

        private void UsersForm_Load(object sender, EventArgs e)
        {
            List<User> userList = DbManager.GetAllUsers();

            foreach (var i in userList)
            {
                dataGridView1.Rows.Add(i.Username.ToString(), i.Password.ToString(), i.UserCategory.UserCategoryName.ToString());
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            AddUserForm f = new AddUserForm();
            f.Show();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            
        }

        private void dataGridView1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            //label2.Text = dataGridView1.CurrentRow.Cells[1].Value.ToString();
            AddUserForm f = new AddUserForm(dataGridView1.CurrentRow.Cells[0].Value.ToString(),
                                            dataGridView1.CurrentRow.Cells[1].Value.ToString(),
                                            dataGridView1.CurrentRow.Cells[2].Value.ToString());
            f.ShowDialog();
        }
    }
}
